﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace DealKhuyenMaiV2.com.Controllers
{
    public class ImageController : Controller
    {
        //
        // GET: /Image/

        [HttpGet]
        public ActionResult GetBase64Image(string curpath)
        {
            string path
                = AppDomain.CurrentDomain.BaseDirectory + curpath;

            FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
            byte[] data = new byte[(int)fileStream.Length];
            fileStream.Read(data, 0, data.Length);

            return Json(new { base64imgage = Convert.ToBase64String(data) }
                , JsonRequestBehavior.AllowGet);
        }
    }
}
